Skip to content

fix(route-proxy): per-leaf first-response timeout (#5294) - #5335

Closed
dezren39 wants to merge 1 commit into
mainfrom
queue/9238-5294-first-response-timeout
Closed

dezren39 wants to merge 1 commit into
mainfrom
queue/9238-5294-first-response-timeout

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Closes #5294

Adds configurable OPENCODE_ROUTE_PROXY_LEAF_TIMEOUT_MS (default 3000 ms) to bound each leaf request until response headers arrive. A per-leaf timeout is recorded as outcome=timeout, error_tag=Transport, with failed_over_to, and the walk continues; client aborts and the existing whole-walk deadline remain terminal.

Adds a proxy regression test proving a hung first leaf is shed and a live second leaf completes within the client window, with both attempts recorded.

Client-side verification: OpenCode reads input.model.routing.policy.firstTokenTimeoutMs; it is configurable via experimental.model_routes.<route>.health.firstTokenTimeoutMs, defaults to 10000 ms, and false disables it. The proxy's 3000 ms default is therefore below the default no-output window.

Tests: node --test bin/opencode-route-proxy.test.mjs (35 passed).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 07:13
@dezren39 dezren39 added the task/small-fix Queue packet kind: bounded fix with reproduction and targeted tests label Nov 4, 2026
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 130e5828-f9e9-4dff-b5a3-0d8481a04612
Commits

Reviewing files that changed from the base of the PR and between 8bb1e43 and 6d6e7bc.

Files selected for processing: 2
  • bin/opencode-route-proxy.mjs
  • bin/opencode-route-proxy.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T07:15:46.520829Z 6d6e7bc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d6e7bc1af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +973 to +978
const leafTimer = setTimeout(
() =>
leafDeadlineCtl.abort(
new Error("opencode-route-proxy leaf first-response timeout"),
),
LEAF_TIMEOUT_MS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve a longer generation deadline for non-streaming requests

For requests with stream omitted or false, an upstream can legitimately wait until the entire completion is generated before sending response headers. Applying this 3-second timer unconditionally therefore aborts healthy non-streaming generations that take longer than three seconds, retries them on subsequent leaves, and ultimately returns 502 if none finishes within that limit. Previously these requests could complete within the existing whole-request deadline. Apply the short first-response timeout only to streaming requests, or provide a separate non-streaming deadline that accommodates full generation.

Useful? React with 👍 / 👎.

@developing-today

Copy link
Copy Markdown
Contributor

🤖 Agent note · superseded (task 12213 triage of issue #5294)

@developing-today developing-today Bot closed this Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

task/small-fix Queue packet kind: bounded fix with reproduction and targeted tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode-route-proxy: per-leg first-response timeout — shed transport-timeout legs inside the client window (#4370b)

1 participant